﻿using System;
using kunukn.RecommendationEngine.AreaRecommendation.Code.Helpers;
using kunukn.RecommendationEngine.AreaRecommendation.Code.Web;


namespace kunukn.RecommendationEngine.AreaRecommendation.Controls.Element
{
    /// <summary>
    /// Author: Kunuk Nykjaer
    /// </summary>
    public partial class ItemThumbnail : MyControl
    {
        public string Name { get; set; }
        public string Color { get; set; }
        public bool LinkEnabled { get; set; }
                
        protected void Page_Load(object sender, EventArgs e)
        {
            this.ItemText.Text = Name;                        
            if (LinkEnabled)
            {
                if(!IsPostBack)
                {
                    string url = Name.GetItemUrl();
                    this.Panel1.Attributes.Add("onclick", string.Format("location.href='{0}'", url));
                    this.Panel1.Attributes.Add("onmouseover", "this.style.cursor='pointer';");
                    this.Panel1.Attributes.Add("onmouseout", "this.style.cursor='default';");
                }
            }

            this.Panel1.Attributes.Add("style", string.Format("background-color: {0}", Color) );           
        }
    }
}